package org.example.controller;

import org.example.common.Result;
import org.example.controller.request.ApplicationReviewRequest;
import org.example.entity.Resources;
import org.example.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/resource")
public class ResourceController {

    @Autowired
    private ResourceService resourceService;

    //查询学生资源申请
    @RequestMapping("/list")
    public Result resourceList() {
        List<Resources> resourceList = resourceService.list();

        return Result.success(resourceList);
    }
    @PostMapping("/applicationReview")
    public Result applicationReview(@RequestBody ApplicationReviewRequest applicationReviewRequest){
        String s;
        if(applicationReviewRequest.getReviewStatus().equals("approved")){
            s="1";
        }else {
            s="2";
        }
resourceService.updateByIdReview(applicationReviewRequest.getId(),s,applicationReviewRequest.getReviewComment());
        return Result.success();
    }
}
